import { createApp } from "vue";
import App from "./App.vue";
import router from "@/router";
import store, { localCacheToVuex } from "@/store";
import "normalize.css";
import "@/assets/css/base.css";

import "ant-design-vue/dist/antd.css";
import Antd from "ant-design-vue";

import { createFromIconfontCN } from "@ant-design/icons-vue";
import { getCache } from "@/utils/cache";
const IconFont = createFromIconfontCN({
  // 获取本地缓存中的iconfont url
  scriptUrl: getCache("settings")?.iconFont
});

localCacheToVuex();

const app = createApp(App);

// 自定义指令校验权限控制 v-permissions
app.directive("permissions", {
  mounted(el, binding) {
    if (store.state.loginStore.userInfo.permissions.indexOf(binding.value) === -1) {
      // 删除元素
      el.parentNode && el.parentNode.removeChild(el);
    }
  }
});

app.component("icon-font", IconFont);
app.use(router);
app.use(store);
app.use(Antd);
app.mount("#app");
